﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Forum.Master" AutoEventWireup="true" CodeBehind="Post.aspx.cs" Inherits="Client.WebForm17" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="keywords" content="travel and tour, free website template, CSS, HTML" />
<meta name="description" content="Travel and Tour - free website template provided by templatemo.com" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Scripts/json2.js"></script>
<script type="text/javascript" src="Scripts/json_parse.js"></script>
<script type="text/javascript" src="Scripts/json_parse_state.js"></script>
<script type="text/javascript" src="Scripts/cycle.js"></script>
<script type="text/javascript" src="Scripts/1.js"></script> 
<script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="Scripts/jquery-1.8.2.js"></script>
    <script src="Scripts/jquery-ui-1.9.1.custom.js"></script>
    <link rel="stylesheet" href="Styles/ThuNhoAnh.css"/>
    <link rel="stylesheet" href="Styles/jquery-ui-1.9.2.custom.css" />
    <link rel="stylesheet" media="screen" href="lib/datatables/css/cleanslate.css" />
     <script type="text/javascript" src="lib/datatables/js/jquery.dataTables.js"></script>
     
     <script>
         $(function () {
             var URL = 'http://localhost:18796/api/values/';
             var array;
             $("#HuyXemNoiDung").hide();
             $(function () {
                 $.ajax({
                     url: URL + '?post=',
                     type: 'GET',
                     datatype: 'json',
                     success: function (data) {
                         array = data;
                         $("#TableComment").empty();
                         for (var i = 0; i < data.length; i++) {
                             $("#TableComment").append(
                                    "<tr class='gradeX'> " +
                                     "   <td>" + data[i].ID + "</td>" +
                                    "    <td>" + data[i].TuaDe + "</td> " +
                                     "   <td>" + data[i].NguoiDang + "</td>   " +
                                   "   <td>" + data[i].NgayDang + "</td>" +

                                   " </tr> "
                            );
                         }
                         $('#example').dataTable();
                     },
                     error: function () {
                         alert('Please Try Again ...');
                     }
                 });
             });
             var b = setInterval(function () {
                 $.ajax({
                     url: URL + '?post=',
                     type: 'GET',
                     datatype: 'json',
                     success: function (data) {
                         array = data;
                         $("#TableComment").empty();
                         for (var i = 0; i < data.length; i++) {
                             $("#TableComment").append(
                                    "<tr class='gradeX'> " +
                                     "   <td>" + data[i].ID + "</td>" +
                                    "    <td>" + data[i].TuaDe + "</td> " +
                                     "   <td>" + data[i].NguoiDang + "</td>   " +
                                   "   <td>" + data[i].NgayDang + "</td>" +

                                   " </tr> "
                            );
                         }
                         $('#example').dataTable();
                     },
                     error: function () {
                         alert('Please Try Again ...');
                     }
                 });
             }, 90000);
             $("#HuyXemNoiDung")
            .button()
            .click(function () {
                $("#XemThuNoiDung").empty();
                $("#XemNoiDung").show();
                $("#HuyXemNoiDung").hide();
            });
             $("#XemNoiDung")
            .button()
            .click(function () {
                try {
                    var index;
                    for (var i = 0; i < array.length; i++) {
                        if (array[i].ID == $("#Text112").val())
                            index = i;
                    }
                    $("#XemThuNoiDung").append(
                    array[index].NoiDung
                    );
                    $("#XemNoiDung").hide();
                    $("#HuyXemNoiDung").show();
                }
                catch (Error) {
                    alert("hãy nhập chính xác stt");
                }
            });
             $("#XoaComment")
            .button()
            .click(function () {
                $.ajax({
                    url: URL + '?DelPost=' + '&id=' + $("#Text112").val(),
                    type: 'GET',
                    datatype: 'json',
                    success: function (data) {
                        if (data == true) {
                            alert("Da Thuc Hien");
                            window.location.reload();
                        }

                        else
                            alert("Khong Thanh Cong");

                    },
                    error: function () {
                        alert('Please Try Again ...');
                    }
                });
            });
         }); 
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="XemThuNoiDung">
</div>
<br />
<div id="Control">
 stt :   <input id="Text112" type="text" />  
    <input id="XemNoiDung" type="button" value="Xem Post" />
    <input id="HuyXemNoiDung" type="button" value="Hủy Xem Post" />
    <input id="XoaComment" type="button" value="Xóa Post" />
</div>
   
<br />
<table class="display" id="example"> 
                                <thead> 
                                    <tr> 
                                        <th>ID</th> 
                                        <th>Tựa Đề</th> 
                                        <th>Người Đăng</th> 
                                        <th>Ngày Đăng</th> 
                                        
                                    </tr> 
                                </thead> 
                                <tbody id="TableComment"> 
                                  
                                  
                                </tbody> 
                            </table> 
</asp:Content>
